/*
 * Copyright 2006-2007 Queplix Corp.
 *
 * Licensed under the Modified Queplix BSD License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.queplix.com/BSDLICENSE-1.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.jlect.swebing.ui.client.laf;

import com.jlect.swebing.ui.client.Color;
import com.jlect.swebing.ui.client.GComponent;

/**
 * UI manager class is in charge of managing all the UI configurations 
 *
 * @author Sergey Kozmin
 * @since Nov 23, 2007
 */
public class UIManager {
    private static UIManager INSTANCE = new UIManager();

    private LookAndFeel laf;

    private UIManager() {
    }

    public static UIManager getInstance() {
        return INSTANCE;
    }

    public void installLAF(LookAndFeel lookAndFeel) {
        if(lookAndFeel == null) {
            throw new IllegalArgumentException("Could not install null Look and Feel object. ");
        }
        if(laf != null) {
            laf.deInitialize();
        }
        laf = lookAndFeel;
        laf.initialize();
    }

    public Color getColor(String colorProperty) {
        return getUIProperties().getColor(colorProperty);
    }

    public ComponentUI getUI(GComponent c) {
        return getUIProperties().getComponentUI(c);
    }

    protected UIProperties getUIProperties() {
        return laf.getDefaultUI();
    }
}
